//
//  HPTextViewInternal+OverrideNextResponder.m
//  MLIM
//
//  Created by molon on 15/7/14.
//  Copyright (c) 2015年 molon. All rights reserved.
//

#import "HPTextViewInternal+OverrideNextResponder.h"
#import <objc/runtime.h>

static char overrideNextResponderKey;

@implementation HPTextViewInternal (OverrideNextResponder)

- (UIResponder *)overrideNextResponder
{
    return objc_getAssociatedObject(self, &overrideNextResponderKey);
}

- (void)setOverrideNextResponder:(UIResponder *)overrideNextResponder
{
    objc_setAssociatedObject(self, &overrideNextResponderKey, overrideNextResponder, OBJC_ASSOCIATION_ASSIGN);
}


- (UIResponder *)nextResponder {
    if (self.overrideNextResponder != nil){
        return self.overrideNextResponder;
    }else{
        return [super nextResponder];
    }
}

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    if (self.overrideNextResponder != nil){
        return NO;
    }else{
        return [super canPerformAction:action withSender:sender];
    }
}

@end
